package com.yswee.mallnavi.view.brand;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import com.yswee.framework.utils.ViewInject;
import com.yswee.framework.widget.base.WebView;
import com.yswee.framework.widget.layoutview.MRelativeLayout;
import com.yswee.mallnavi.R;
import com.yswee.mallnavi.entity.info.BrandEntity;


/***
 */
public class InfoView extends MRelativeLayout<BrandEntity> {

    @ViewInject
    private View imgback;
    @ViewInject
    private ViewGroup uvwebview;

    private  IActionCallback mActionCallback;

    public void setActionCallback(IActionCallback c) {
        mActionCallback = c;
    }

    public InfoView(Context context) {
        super(context);
    }

    public InfoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.view_info_brand_info;
    }

    @Override
    protected void onBindListener() {
        super.onBindListener();
        imgback.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mActionCallback != null) {
                    mActionCallback.onBackClicked(InfoView.this);
                }
            }
        });
    }

    @Override
    protected void onApplyData() {
        String htmlContent = mDataItem.getDescription();
        WebView.newWebview(uvwebview, htmlContent);
    }

    @Override
    public void setVisibility(int visibility) {
        if (visibility == GONE || visibility == INVISIBLE) {
            WebView.releaseWebview();
        }
        super.setVisibility(visibility);
    }

    public interface IActionCallback {
        void onBackClicked(View v);
    }

}